package coms.ejb.sessionbean;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;


import coms.dataaccess.ConferenceItemDAO;
import coms.dataaccess.DAOFactory;

import coms.datatransfer.ConferenceItemDTO;


/**
 * Session Bean implementation class ConferenceItemBean
 */
@Stateless(name="ConferenceItemBean", mappedName = "ConferenceItemBean")
@Remote(ConferenceItemBeanRemote.class)
public class ConferenceItemBean implements ConferenceItemBeanRemote {

	private ConferenceItemDAO conferenceItemDAO = null;
	
	public ConferenceItemBean() {}
	
	public void ejbCreate(){
		conferenceItemDAO = DAOFactory.getInstance().getConferenceItemDAO();
	}
	
	public List<ConferenceItemDTO> findAllConferenceItemByConfId(int ConferenceId) throws Exception{
		List<Object[]> confItemList = conferenceItemDAO.findAllConferenceItemByConfId(ConferenceId);
		List<ConferenceItemDTO> conferenceItemList = new ArrayList<ConferenceItemDTO>();
		for (Object[] r: confItemList)
		{
			conferenceItemList.add((ConferenceItemDTO)r[0]);
		}
		return conferenceItemList;
	}

	@Override
	public void createConferenceItem(ConferenceItemDTO conferenceItem) {
		conferenceItemDAO.insertConferenceItem(conferenceItem);
	}

}
